<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<view style="background-image: url(../../static/img/banner-weibao.png); background-size: cover; height: 210px;">
			<u-navbar title-color="#FFFFFF" back-icon-color="#FFFFFF" height="48" :background="{opacity: 1}" :border-bottom="false" :is-fixed="true" :title="'检测中心'"></u-navbar>
		</view>
		
		<u-grid col="1" :border="false" style="margin-top: -23px; width: 84%; margin-left: 8%;">
			<u-grid-item v-for="(item,index) in menuList" :name="item.title" :key="index" :index="index" @click="itemClick(item)">
				<view :class="item.code">
					<image style="height: 80px; width: 80px;" :src="item.icon">
					<text>{{item.title}}</text>
				</view>
				<!-- <u-badge v-if="item.badge!=0" :count="item.badge" :offset="[20,30]"></u-badge>
				<u-icon :name="item.icon" :color="item.color" custom-prefix="el-icon-if" :size="46"></u-icon>
				<view class="grid-text">{{item.title}}</view> -->
			</u-grid-item>
		</u-grid>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuList:[
					{
						badge:0,
						icon:'../../static/img/weibaorenwu.png',
						color:"#5098FF",
						title:"检测任务",
						code: "wbrw",
						path:'/pages/testing/list',
					}
				],
			}
		},
		computed:{
			hiddenButton(){
				let roleCode = this.$store.getters.roleCode;
				return roleCode=="XFZD-ADMIN"||roleCode=="XT-ADMIN"||roleCode=="ZD-ADMIN"||roleCode=="DD-ADMIN"||roleCode=="JW-ADMIN"||roleCode=="XZ-ADMIN"
			}
		},
		onShow() {
			this.menuList=[
				{
					badge:0,
					icon:'../../static/img/weibaorenwu.png',
					color:"#5098FF",
					title:"检测任务",
					code: "wbrw",
					path:'/pages/testing/list',
				}
			]
			if(this.hiddenButton){
				this.addMenu()
			}
		},
		methods: {
			itemClick(item){
				if(item.title=="发起演练"){
					//判断用户的角色数据
					if(this.$store.getters.roleCode=="XZ-ADMIN"){
						uni.navigateTo({
							url:item.path
						})
					}else{
						uni.navigateTo({
							url:"/pages/index/choice/choice"
						})
					}
				}else{
					uni.navigateTo({
						url:item.path
					})
				}
			},
			addMenu(){
				this.menuList.push({
					badge:0,
					icon:'xunjian',
					color:"#5098FF",
					title:"发起演练",
					path:'/pages/index/drill/drillNotice'})
			},
			OpenTel(){
				window.native.getLocation(res=>{
					console.log(res)
				})
			},
			test(){
				window.native.h5Camera(res=>{
					
				})
				window.native.getUri(res=>{
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss">
	.jz{
		background: #E7F8FF;
		box-shadow: 0 0 6px 0 #999999;
		padding: 9.6% 0 9.6% 0;
		border-radius: 4px;
		height: 140px;
		width: 100%;
		margin-bottom: 3%;
		text-align: center;
		uni-text{
			    height: 80px;
			    line-height: 80px;
			    margin-left: 10px;
			    font-family: PingFangSC-Medium;
			    font-size: 16px;
			    color: #1A5DC3;
			    letter-spacing: 0.26px;
				vertical-align: bottom;
		}
	}
	
	.wbgd{
		background: #E5FBF2;
		box-shadow: 0 0 6px 0 #999999;
		padding: 9.6% 0 9.6% 0;
		border-radius: 4px;
		height: 140px;
		width: 100%;
		margin-bottom: 3%;
		text-align: center;
		uni-text{
			    height: 80px;
			    line-height: 80px;
			    margin-left: 10px;
			    font-family: PingFangSC-Medium;
			    font-size: 16px;
			    color: #40BD9B;
			    letter-spacing: 0.26px;
				vertical-align: bottom;
		}
	}
	
	.wbrw{
		background: #E7E5FF;
		box-shadow: 0 0 6px 0 #999999;
		padding: 9.6% 0 9.6% 0;
		border-radius: 4px;
		height: 140px;
		width: 100%;
		margin-bottom: 3%;
		text-align: center;
		uni-text{
			    height: 80px;
			    line-height: 80px;
			    margin-left: 10px;
			    font-family: PingFangSC-Medium;
			    font-size: 16px;
			    color:  #8A7DFF;
			    letter-spacing: 0.26px;
				vertical-align: bottom;
		}
	}
</style>
